package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.form.BrokerTrainingRecordForm;
import com.yxinsur.imc.business.vo.BrokerTrainingRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.business.domain.ImcBrokerTrainingRecord;
import com.yxinsur.imc.business.service.IImcBrokerTrainingRecordService;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 代理人培训记录Controller
 * 
 * @author imc
 * @date 2021-07-26
 */
@RestController
@Api(value = "代理人训练记录服务接口",tags = "14.代理人训练记录接口")
@RequestMapping("/business/training")
public class ImcBrokerTrainingRecordController extends BaseController
{
    @Autowired
    private IImcBrokerTrainingRecordService imcBrokerTrainingRecordService;

    /**
     * 查询代理人培训记录列表
     */
    @GetMapping("/list")
    @ApiOperation("代理人培训记录分页列表查询")
    public TableDataInfo list(BrokerTrainingRecordForm brokerTrainingRecordForm)
    {
        startPage();
        List<BrokerTrainingRecordVo> list = imcBrokerTrainingRecordService.selectImcBrokerTrainingRecordList(brokerTrainingRecordForm);
        return getDataTable(list);
    }

    /**
     * 导出代理人培训记录列表
     */
    @Log(title = "代理人培训记录", businessType = BusinessType.EXPORT)
    @ApiOperation("代理人培训记录导出数据")
    @GetMapping("/export")
    public AjaxResult export(BrokerTrainingRecordForm brokerTrainingRecordForm)
    {
        List<BrokerTrainingRecordVo> list = imcBrokerTrainingRecordService.selectImcBrokerTrainingRecordList(brokerTrainingRecordForm);
        ExcelUtil<BrokerTrainingRecordVo> util = new ExcelUtil<BrokerTrainingRecordVo>(BrokerTrainingRecordVo.class);
        return util.exportExcel(list, "代理人培训记录导出");
    }

    /**
     * 新增代理人培训记录
     */
    @Log(title = "代理人培训记录", businessType = BusinessType.INSERT)
    @ApiOperation("代理人培训记录新增")
    @PostMapping
    public AjaxResult add(@RequestBody BrokerTrainingRecordForm brokerTrainingRecordForm)
    {
        return toAjax(imcBrokerTrainingRecordService.insertImcBrokerTrainingRecord(brokerTrainingRecordForm));
    }

    /**
     * 修改代理人培训记录
     */
    @Log(title = "代理人培训记录", businessType = BusinessType.UPDATE)
    @ApiOperation("代理人培训记录更新")
    @PutMapping
    public AjaxResult edit(@RequestBody BrokerTrainingRecordForm brokerTrainingRecordForm)
    {
        return toAjax(imcBrokerTrainingRecordService.updateImcBrokerTrainingRecord(brokerTrainingRecordForm));
    }

    /**
     * 删除代理人培训记录
     */
    @Log(title = "代理人培训记录", businessType = BusinessType.DELETE)
    @ApiOperation("代理人培训记录删除")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imcBrokerTrainingRecordService.deleteImcBrokerTrainingRecordByIds(ids));
    }
}
